from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import selectinload

from model.user import RespawnCourier, AddressList


class CRUDRespawn:
    async def get_respawn_by_user_id(self, user_id: int, db_session: AsyncSession):
        return (await db_session.execute(select(RespawnCourier)
                                        .where(RespawnCourier.id_user == user_id)
                                        .options(selectinload(RespawnCourier.address),
                                                 selectinload(RespawnCourier.user)))).scalar()

    async def get_couriers_by_address_id(self):
        pass


respawn = CRUDRespawn()
